<?php

$params = require(__DIR__ . '/params.php');

$config = [
	'id' => 'basic',
	'language' => 'zh-CN',
	'basePath' => dirname(__DIR__),
	'bootstrap' => ['log'],
	'modules' => [
		'admin' => [
			'class' => 'app\modules\admin\Module',
			'layout' => '_adminlte.php',
			'defaultRoute' => 'index',
			/*'components' => [
				'errorHandler' => [
					'class' => '',
					'errorAction' => 'admin/default/error',
				],
				'user' => [
					'class'=>User
					'identityClass' => 'app\models\Admin',
					'enableAutoLogin' => false,
					'loginUrl' => ['/backend/login'],
				],
				'homeUrl' => '/admin/index/index',
			],*/
			'as access' => [ // 使用第三方的访问控制
				'class' => 'app\modules\admin\components\AccessControl',
				'allowActions' => [
					'default/login',
					'default/captcha',
				],
			],
		],
		'mdm' => [
			'class' => 'mdm\admin\Module',
			'layout' => 'left-menu',
		],
	],
	'components' => [
		'request' => [
			'cookieValidationKey' => 'K-39F2-XIZ_-KgxqnlpLqr46bhF6_kEr',
		],
		'cache' => [
			'class' => 'yii\caching\FileCache',
		],
		'user' => [
			'identityClass' => 'app\models\User',
			'enableAutoLogin' => true,
		],
		'errorHandler' => [
			'errorAction' => 'site/error',
		],
		'mailer' => [
			'class' => 'yii\swiftmailer\Mailer',
			// send all mails to a file by default. You have to set
			// 'useFileTransport' to false and configure a transport
			// for the mailer to send real emails.
			'useFileTransport' => true,
		],
		'log' => [
			'traceLevel' => YII_DEBUG ? 3 : 0,
			'targets' => [
				[
					'class' => 'yii\log\FileTarget',
					'levels' => ['error', 'warning'],
				],
			],
		],
		'db' => require(__DIR__ . '/db.php'),
		/* 路由配置 */
		'urlManager' => [
			'enablePrettyUrl' => true,
			'showScriptName' => false,
			'rules' => [
			],
		],
		/* 启用RBAC */
		'authManager' => [
			'class' => 'app\Modules\admin\components\DbManager', // 使用数据库管理权限Rbac
		],
	],

	'params' => $params,
];

if (YII_ENV_DEV) {
	// configuration adjustments for 'dev' environment
	/*$config['bootstrap'][] = 'debug';
	$config['modules']['debug'] = [
		'class' => 'yii\debug\Module',
	];*/

	$config['bootstrap'][] = 'gii';
	$config['modules']['gii'] = [
		'class' => 'yii\gii\Module',
	];
}

return $config;
